package com.moxiao.yfjh.module.order.common;

import org.apache.commons.lang3.time.DateFormatUtils;

import java.util.Date;
import java.util.Random;
import java.util.UUID;

/**
 * 生成流水号统一工具类
 **/
public class NoCommonUtil {

    private static final String PREFIX_MEMBER_ORDER = "HYDD";
    private static final String PREFIX_MEMBER_USER = "JFHY";
    private static final String PREFIX_MEMBER_DISTRIBUTION = "FXYJ";
    private static final String PREFIX_MEMBER_WITHDRAW = "TX";

    /**
     * 生成分销佣金流水号：FXYJ-20180808999
     */
    public static String getDistribution(Long id) {
        String no = PREFIX_MEMBER_DISTRIBUTION + "-" + dateTime() + getRandom() + id;
        return no;
    }

    /**
     * 流水号
     */
    public static String getNo() {
        String no = PREFIX_MEMBER_WITHDRAW + "-" + dateTime() + getRandom();
        return no;
    }

    /**
     * 日期路径 即年/月/日 如20180808
     */
    public static String dateTime() {
        Date now = new Date();
        return DateFormatUtils.format(now, "yyyyMMdd");
    }

    /**
     * 生成一个范围在0到999之间的随机整数
     */
    public static int getRandom() {
        Random random = new Random();
        int randomNumber = random.nextInt(9999);
        return randomNumber;
    }

}
